<template>
  <div class='search'>
    <f-drawer ref='invoiceDrawer' :show-footer='false' :title='title' width='87%' @visibleChange='visibleChange'>
      <sale-man-settle-details ref='form1' :invoiceData='invoiceData' :isMonitor='isMonitor' :columns='columns' v-if='drawerVisible'></sale-man-settle-details>
    </f-drawer>
  </div>
</template>
<script>
import SaleManSettleDetails from "./saleman_settle_details"

export default {
  name: "SaleManSettleDetailsDrawer",
  props: {
    invoiceData: {
      type: Object,
      default: null
    },
    isMonitor:{
      type: Object,
      default: false
    },
  },
  data() {
    return {
      refs: this.$refs,
      drawerVisible: false,
      isEdit: false,
      title: "",
      current: "form1",
      formData: {},
      columns: null,
      forms: [
        "form1"
      ]
    }
  },
  methods: {
    getCol(data) {
      return [
        {
          title: "序号",
          width: "60px",
          align: "left",
          fixed: "left",
          dataIndex: "rowIndex",
          customRender: function(text, record, index) {
            return (record.rowIndex !== "合计") ? (parseInt(index) + 1) : record.rowIndex
          }
        },
        {
          title: "发货日期",
          align: "center",
          sorter: true,
          fixed: "left",
          dataIndex: "sendDate"
        },
        {
          title: "发货单号",
          align: "center",
          width: "130px",
          fixed: "left",
          dataIndex: "outOrderNo"
        },
        {
          title: "部门名称",
          align: "left",
          sorter: true,
          width: "100px",
          dataIndex: "deptName"
        },
        {
          title: "业务员",
          align: "center",
          width: "80px",
          sorter: true,
          ellipsis: true,
          dataIndex: "saleManName"
        },
        {
          title: "业务员编码",
          align: "left",
          width: "100px",
          dataIndex: "businessCode"
        },
       
        {
          title: "类型",
          align: "center",
          width: "80px",
          dataIndex: "drugType",
          scopedSlots: { customRender: "drugType" }
        },
        {
          title: "发货方式",
          align: "center",
          width: "100px",
          dataIndex: "sendType",
          scopedSlots: { customRender: "sendType" }
        },
        {
          title: "单位名称",
          align: "left",
          width: "130px",
          sorter: true,
          ellipsis: true,
          dataIndex: "customName"
        },
        {
          title: "商品名称",
          align: "left",
          ellipsis: true,
          width: "140px",
          sorter: true,
          dataIndex: "drugsName"
        },
        {
          title: "规格",
          align: "left",
          width: "80px",
          ellipsis: true,
          dataIndex: "drugsSpec"
        },
        {
          title: "回款金额",
          align: "center",
          width: "80px",
          needTotal: true,
          dataIndex: "returnAmount"
        },
        {
          title: "回款日期",
          align: "center",
          sorter: true,
          width: "120px",
          dataIndex: "returnDate"
        },
        {
          title: "数量",
          align: "center",
          width: "80px",
          dataIndex: "saleNum"
        },
        {
          title: "单价",
          align: "center",
          fixed: "right",
          dataIndex: "salePrice"
        },
        {
          title: "销售金额",
          align: "center",
          width: "80px",
          fixed: "right",
          needTotal: true,
          type: 10,
          dataIndex: "saleAmount"
        },
        {
          title: "结算金额",
          align: "center",
          width: "110px",
          fixed: "right",
          type: 10,
          needTotal: true,
          dataIndex: "settleAmount"
        },
        {
          title: "操作",
          align: "center",
          width: "120px",
          dataIndex: "action",
          fixed: "right",
          scopedSlots: { customRender: "action" }
        }
      ]
    },
    showDrawer(data) {
      this.formData = data
      this.columns = this.getCol(data)
      this.refs["invoiceDrawer"].show(data)
      this.title=data.saleManName+"-结算明细"
      this.$nextTick(() => {
        this.refs["form1"].setData(this.formData)
      })
    },
  
    visibleChange(drawerVisible) {
      this.drawerVisible = drawerVisible
    },
    tabClick(name) {
      this.current = name
      this.$nextTick(() => {
        this.refs[this.current].setData(this.formData)
      })
    }
  },
  created() {
  },
  components: { SaleManSettleDetails }
}
</script>

<style scoped lang='less' rel='stylesheet/less'>

</style>
